import {HTTP} from "../../utils/http.js";

import {MessageModel} from "../../models/message.js";
var _MessageModel = new MessageModel();
import { UserModel } from "../../models/user.js";
var _UserModel = new UserModel();
var http = new HTTP();
const app = getApp();
var _self;
Page({
  data: {
    tabList: [
      { name: "好友", page: 0 },{ name: "发现", page: 1 }
    ],
    currentTab:0,
    currentSwiperPage:0,
    wbImageSize:[],
    
  },
  onLoad: function () {
    _self = this;
    this.setData({
      windowHeight: app.globalData.windowHeight
    })
  },
  _switchNav: function (e) {
    this.setData({
      currentSwiperPage: e.currentTarget.dataset.current,
      currentTab: e.currentTarget.dataset.current
    })
    this.getPageInitData()
  },
  _bindSwiperChange: function (e) {
    this.setData({
      currentSwiperPage: e.detail.current,
      currentTab: e.detail.current
    })
    this.getPageInitData()
  },
  getPageInitData:function(){
    if (this.data.currentTab == 0) {

    }
    if (this.data.currentTab == 1) {
      //加载发布的消息
     
    }
  },
  onShow:function(){
    //进入主页　调用看看有没有新消息　有设置在tabbar上显示
    _UserModel.getUsrMessage(function (data) {
      if (data[0].list.length > 0) {
        wx.setTabBarBadge({
          index: 2,
          text: data[0].list.length + ''
        })
      } else {
        wx.removeTabBarBadge({
          index: 2
        })
      }
    })  
  },
  scroll:function(e){
  }
})
